<template>
  <div id="app">
    <router-view v-if="isRouterAlive"/>
  </div>
</template>

<script>
export default {
  provide(){
    return {
      reload:this.reload
    }
  },
  data(){
    return{
      isRouterAlive:true
    }
  },
  beforeCreate(){
  },
  created(){
    let showType = localStorage.getItem('showType');
    this.changeShowType(showType);
  },
  methods:{
    //页面重新加载，不完全刷新，未用到
    reload(){
      this.isRouterAlive = false;
      this.$nextTick(function(){
        this.isRouterAlive = true;
      })
    },
    changeShowType(showType){
      if(showType == 'mobile' || (showType == null && window.screen.height > window.screen.width)){
        this.global.showType = 'mobile';
        this.global.isPc = false;
      }else{
        this.global.showType = 'pc';
        this.global.isPc = true;
      }
    }
  },
  // watch:{
  //   "$route.query.showType": function(newVal, oldVal){
  //     //或者这里直接监听global.showType应该也可以...
  //     //进来证明有值，或者从有值变为无值
  //     this.changeShowType();
  //     // console.log(newVal);
  //     // console.log(oldVal);
  //     // console.log(this.global.showType);
  //     // console.log(this.$route.query.showType);
  //     if(this.$route.query.showType){
  //       // let showTypeTemp = localStorage.getItem('showTypeTemp');
  //       // if(this.global.showType != this.$route.query.showType){
  //         // localStorage.setItem('showTypeTemp', this.$route.query.showType);
  //         this.global.showType = this.$route.query.showType;
  //         //会一直不停刷新
  //         // location.reload();
  //       // }
  //       if(this.global.showType = 'pc'){
  //         this.global.isPc = true;
  //       }else{
  //         this.global.isPc = false;
  //       }
  //     }
  //     // console.log('refresh');
  //     this.reload();
  //   }
  // }
}
</script>

<style lang='scss'>
html, body{
  margin: 0;
  padding: 0;
  font-size: $base-fsize;
}
p {
  margin: 10px 0;
}
a {
  color: #333;
  text-decoration: none;
}
a:hover {
  color: $base-color;
}
.a-span{
  color: #333;
  text-decoration: none;
  cursor: pointer;
}
.a-span:hover{
  color: $base-color;
}
.el-pagination{
  text-align: center!important;
}
.el-pager li.active{
  background-color: $base-color!important;
}
.el-pagination-slot{
  font-weight: normal;
  color: #606266;
}
.hidden{
  display: none;
}

.el-message-box__wrapper .el-message-box_custom {
  width: 370px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* bottom: 0; */
  /* right: 0; */
  /* text-align: center; */
  /* left: 50%; */
  /* transform: translateY(-50%); */
  /* vertical-align: middle; */
}
</style>
